package com.yeskery.nut.extend.mcp.server;

import com.yeskery.nut.extend.responsive.ResponsiveConvert;
import com.yeskery.nut.util.JsonNullRemover;

/**
 * 响应转换扩展接口
 * @author sprout
 * 2025-04-24 10:00
 */
public interface ResponsiveConvertExpanded {

    /**
     * 从 {@link java.lang.Object} 转换成 {@link T} 类型
     * @param responsiveConvert {@link ResponsiveConvert} 对象
     * @param data {@link java.lang.String} 对象
     * @param clazz 类对象
     * @param <T> {@link T} 类型
     * @return {@link T} 对象
     */
    default <T> T converFromObject(ResponsiveConvert responsiveConvert, Object data, Class<T> clazz) {
        return responsiveConvert.convertFromString(JsonNullRemover.removeNullOrEmptyFields(responsiveConvert.convertTo(data)), clazz);
    }
}
